<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Create account form template
 *
 * @see app/design/frontend/base/default/template/customer/form/register.phtml
 */
/** @var $this Mage_Customer_Block_Form_Register */
?>


<div class="wrapper-main">
    <div class="headlabel"><?php echo $this->__('SIGN IN') ?></div><br />
    <p class="notes"><?php echo $this->__('* Indicate required field') ?></p><br />
    <?php echo $this->getChildHtml('form_fields_before')?>
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <form class="jNice" action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
        <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
        <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
          <div class="content-create">
                <div class="col-1">
                    <div class="box-left register">
                        <h4><?php echo $this->__('Your Information') ?></h4>
                        <div class="content-box">
                            <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
                        
                        <fieldset>
                                <label for="company" class="required"><?php echo $this->__('Company Name') ?><span>*</span></label>
                                <input type="text" name="company" class="required-entry" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company Name') ?>" class="<?php echo $this->helper('customer/address')->getAttributeValidationClass('companyname') ?>" />
                        </fieldset>
                        </div>
                        
                    </div><!--end box left-->
                    <div class="box-left register">
                        <h4><?php echo $this->__('Your Name &amp; Password') ?></h4>
                        <div class="content-box">
                            <fieldset>
                                    <?php $email = $this->getRequest()->getParam("email"); ?>
                                    <?php if(empty($email)):?>
                                        <label for="email_address" class="required"><?php echo $this->__('Email') ?><span>*</span></label>
                                        <input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry" />     
                                    <?php else:?>    
                                        <label for="email_address" class="required"><?php echo $this->__('Email') ?><span>*</span></label>
                                        <input type="text" name="email" id="email_address" value="<?php echo $email ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry" />     
                                    <?php endif;?>
                                    
                            </fieldset>
                            <fieldset>
                                    <label for="password" class="required"><?php echo $this->__('Password') ?><span>*</span></label>
                                    <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="required-entry validate-password" />                                    
                            </fieldset>
                            <fieldset>
                                    <label for="confirmation" class="required"><?php echo $this->__('Confirm Password') ?><span>*</span></label>
                                    <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="required-entry validate-cpassword" />
                            </fieldset>

                        </div>
                    </div><!--end box left-->
                    <div class="box-left register">
                        <h4><?php echo $this->__("Contact Information") ?></h4>
                        <div class="content-box">
                            <fieldset>                                  
                                    <label for="telephone" class="required"><?php echo $this->__('Phone') ?><span>*</span></label>
                                    <input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="<?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />                                   
                            </fieldset>
                            
                            <fieldset>
                                <label><?php echo $this->__("Fax") ?><span></span></label>
                                <input type="text" name="fax" class="" id="fax" value="<?php echo $this->escapeHtml($this->getFormData()->getFax()) ?>" />
                            </fieldset>
                            <fieldset>
                                    <label><?php echo $this->__("Website") ?><span></span></label>
                                    <input type="text" name="account_website" class="" id="account_website" value="<?php echo $this->escapeHtml($this->getFormData()->getAccountWebsite()) ?>" />
                            </fieldset>
                        </div>
                    </div><!--end box left-->
                    <div class="box-left register">
                        <h4><?php echo $this->__("Company Information") ?></h4>
                        <div class="content-box">
                            <fieldset>
                                <p class="bold">Please tell us a little about your business and how<br /> you like to use our parts?</p><br />
                                <p>*(In 500 words or less)</p>
                            </fieldset>

                            <fieldset>
                                <textarea id="company_info" maxlength="500" class="required-entry" name="company_info"><?php echo $this->escapeHtml($this->getFormData()->getCompanyInfo()) ?></textarea>
                            </fieldset>
                        </div>
                    </div><!--end box left-->
                </div>
              <?php $this->setShowAddressFields(true); ?>
              <?php if($this->getShowAddressFields()): ?>
               <?php $street = $this->getFormData()->getStreet(); ?>
                <input type="hidden" name="create_address" value="1" />
                <div class="col-2">
                    <div class="box-left register">
                        <h4><?php echo $this->__("Billing Address") ?></h4>
                        <div class="content-box">

                            <fieldset>
                                    <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
                                    <label for="street_1" class="required"><?php echo $this->__('Address') ?><span>*</span></label>
                                    <input type="text" name="street[]" value="<?php echo $this->escapeHtml(@$street[0]) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="<?php echo $_streetValidationClass ?>" />                                   
                            </fieldset>
                            
                            <?php for ($_i = 1, $_n = $this->helper('customer/address')->getStreetLines(); $_i < $_n; $_i++): ?>
                            <fieldset>
                                <label for="street_2" class=""><?php echo $this->__('Address 2') ?></label>
                                <input type="text" name="street[]" value="<?php echo $this->escapeHtml($street[$_i]) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo ($_i+1) ?>" class="input-text <?php //echo $_streetValidationClass ?>" />
                            </fieldset>
                            <?php endfor; ?>
                            <fieldset>
                                    <label for="city" class="required"><?php echo $this->__('City') ?><span>*</span></label>
                                    <input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="<?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
                            </fieldset>
                            <fieldset>
                                    <label for="region_id" class="required"><?php echo $this->__('State/Province') ?><span>*</span></label>
                                    <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
                                        <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
                                    </select>
                                    <script type="text/javascript">
                                    //<![CDATA[
                                        $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
                                    //]]>
                                    </script>
                                    <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                                    
                            </fieldset>
                            <fieldset>
                                    <label for="country" class="required"><?php echo $this->__('Country') ?><span>*</span></label>
                                    <?php echo $this->getCountryHtmlSelect() ?>
                            </fieldset>
                            <fieldset>
                                    <label for="zip" class="required"><?php echo $this->__('Zip/Postal Code') ?><span>*</span></label>
                                    <input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="zipcode validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                            </fieldset>
                        </div>
                    </div><!--end box left-->
                    <input type="hidden" name="create_shipping_address" value="1" />
                    <div class="box-left register">
                        <h4><?php echo $this->__("Shipping Address") ?></h4>
                        <div class="content-box">
                            <fieldset> <input type="checkbox" name="same_as_billing" id="same_as_billing"  value="1" /><span class="text-check"><?php echo $this->__("Same as billing") ?> </span></fieldset>
                            <!--<fieldset> <input type="checkbox" value="1" /><span class="text-check">Is this a Residence?</span></fieldset>-->
                            <div id="shipping_id">
                                <?php $shipping_street = $this->getFormData()->getShippingStreet(); ?>
                                <fieldset>
                                        <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
                                        <label for="street_1" class="required"><?php echo $this->__('Address') ?><span>*</span></label>
                                        <input type="text" id="shipping_street_1" name="shipping_street[]" value="<?php echo @$shipping_street[0] ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="<?php echo $_streetValidationClass ?>" />
                                </fieldset>
                                <fieldset>
                                        <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
                                        <label for="street_2" class=""><?php echo $this->__('Address 2') ?></label>
                                        <input type="text" id="shipping_street_2" name="shipping_street[]" value="<?php echo @$shipping_street[1] ?>" title="<?php echo $this->__('Street Address') ?>" class="<?php //echo $_streetValidationClass ?>" />
                                </fieldset>

                                <fieldset>
                                        <label for="city" class="required"><?php echo $this->__('City') ?><span>*</span></label>
                                        <input type="text" id="shipping_city" name="shipping_city" value="<?php echo $this->escapeHtml($this->getFormData()->getShippingCity()) ?>" title="<?php echo $this->__('City') ?>" class="<?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"/>
                                </fieldset>

                                <fieldset>
                                        <label for="region_id" class="required"><?php echo $this->__('State/Province') ?><span>*</span></label>
                                        <select class="validate-select required-entry" id="shipping_region_id" name="shipping_region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
                                            <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
                                        </select>
                                        <script type="text/javascript">
                                        //<![CDATA[
                                            $('shipping_region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getShippingRegionId() ?>");
                                        //]]>
                                        </script>
                                        <input type="text" class="required-entry" id="shipping_region" name="shipping_region" value="<?php echo $this->escapeHtml($this->getFormData()->getShippingRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
                                </fieldset>
                                <fieldset>
                                    <label for="shipping_country" class="required"><?php echo $this->__('Country') ?><span>*</span></label>
                                    <?php $country_id = $this->escapeHtml($this->getFormData()->getShippingCountry()) ?>
                                    <?php $_countries = Mage::getResourceModel('directory/country_collection')
                                            ->loadData()
                                            ->toOptionArray(false) ?>
                                    <?php if (count($_countries) > 0): ?>
                                        <select class="validate-select required-entry" name="shipping_country" id="shipping_country">

                                            <?php foreach($_countries as $_country): ?>
                                                <?php if($country_id == $_country['value']): ?>
                                                    <option selected value="<?php echo $_country['value'] ?>">
                                                        <?php echo $_country['label'] ?>
                                                    </option>
                                                <?php elseif($_country['value'] == "US"):?>    

                                                    <option selected value="<?php echo $_country['value'] ?>">
                                                        <?php echo $_country['label'] ?>
                                                    </option>
                                                <?php else:?>    
                                                    <option value="<?php echo $_country['value'] ?>">
                                                        <?php echo $_country['label'] ?>
                                                    </option>    
                                                <?php endif;?>
                                            <?php endforeach; ?>
                                        </select>
                                    <?php endif; ?>
                                </fieldset>
                                <fieldset>
                                        <label for="shipping_poscode" class="required"><?php echo $this->__('Zip/Postal Code') ?><span>*</span></label>
                                        <input type="text" name="shipping_postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getShippingPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="shipping_zip" class="zipcode validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
                                </fieldset>
                            </div>
                        </div>
                    </div><!--end box left-->
                    <input type="hidden" name="default_billing" value="1" />
                    <input type="hidden" name="shipping_default_shipping" value="1" />
                    <?php endif;?>
                    
                </div><!--end col 2-->
                 <div class="bottom clear">
                        <fieldset class="acept">
                            <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
                            <span class="bold">  <?php echo $this->__("Yes, I would like to receive newsletter!") ?></span>
                        </fieldset>
                        <fieldset>
                            <button type="submit" title="<?php echo $this->__('Submit') ?>" class="submit"><span><span><?php echo $this->__('Submit') ?></span></span></button>
                            <button type="reset" class="cancel" value="Cancel" onclick="window.location='<?php echo $this->getUrl(); ?>'; return false;" ><span><span><?php echo $this->__('Cancel') ?></span></span></button>
                        </fieldset>
                </div>
          </div>
      </form>
    <script type="text/javascript">

    //<![CDATA[
        
        var dataForm = new VarienForm('form-validate', true);
      
        <?php if($this->getShowAddressFields()): ?>
        new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
        new RegionUpdater('shipping_country', 'shipping_region', 'shipping_region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
        <?php endif; ?>      
    //]]>
    </script>
      <div class="clear"></div>
</div>



